package com.example.springbootdaydayup.controller;

import com.example.springbootdaydayup.entity.ChoumaWeek;
import org.beetl.sql.core.SQLManager;
import org.beetl.sql.ext.spring4.SqlManagerFactoryBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


/* 数据获取controller*/
@Controller
@RequestMapping("/getData")
public class DataController {

    @Autowired
    SqlManagerFactoryBean sqlManagerFactoryBean;

    //有了 SqlManagerFactoryBean 对象会自动生成这个对象
    @Autowired
    public SQLManager sqlmanager;


    /**
     *查询周数据
     */
    @RequestMapping(value = "/getWeek")
    @ResponseBody
    public List<ChoumaWeek> getWeek(String name) {

        Map<String, String> params = new HashMap<>();


        if("".equals(name)){
            name=null;
        }

        params.put("name",name);

        List<ChoumaWeek> list = sqlmanager.select("week.select", ChoumaWeek.class, params);

        return list;
    }



}
